<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\search\AuthAccountSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '授权账号';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="auth-account-index">
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
                'attribute'=>'id',
                'options' => ['width' => '80px'],
            ],
            [
                'attribute'=>'uid',
                'options' => ['width' => '60px'],
//                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    return Html::a($model->user->showAvatar(),['index','AuthAccountSearch[uid]'=>$model->uid]).'<br/>'.$model->user->nickname;
                }
            ],
            [
                'attribute'=>'auth_app_id',
                'options' => ['width' => '60px'],
//                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    return Html::a($model->authApp->showLogo(),['index','AuthAccountSearch[auth_app_id]'=>$model->auth_app_id]);
                }
            ],
//            'app_uid',
//            'open_id',
            [
                'attribute'=> 'open_id',
                'options' => ['width' => '60px'],
//                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    return $model->showAvatar();
                }
            ],
            [
                'attribute'=>'nickname',
                'options' => ['width' => '200px'],
            ],
            [
                'attribute'=>'note_name',
                'options' => ['width' => '200px'],
            ],
            [
                'attribute'=>'auth_item_nums',
                'options' => ['width' => '60px'],
                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    return Html::a($model->auth_item_nums,['auth-item/index','AuthItemSearch[auth_account_id]'=>$model->id]);
                }
            ],
            [
                'attribute'=>'last_auth_item_id',
                'options' => ['width' => '60px'],
                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    if(!$model->lastAuthItem) return '无';
                    return Html::a($model->lastAuthItem->showCover(),['auth-item/index','AuthItemSearch[id]'=>$model->last_auth_item_id]);
                }
            ],
            [
                'attribute'=>'last_auth_item_time',
                'options' => ['width' => '60px'],
                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    if(!$model->lastAuthItem) return '无';
                    return date('Y-m-d H:i:s',$model->last_auth_item_time);
                }
            ],
            //'token',
            //'token_expire_time:datetime',
            //'refresh_token',
            //'refresh_token_expire_time:datetime',
            //'refresh_token_get_nums',
            [

                'attribute'=>'all_expire_time',
                'options' => ['width' => '160px'],
                'filter'=>false,
//                'format'=>'raw',
                'value'=>function($model){
                    return date('Y-m-d H:i:s',$model->all_expire_time);
                }
            ],
        ],
    ]); ?>


</div>
